var vm_jintieshoukuan = new Vue({
    el: "#jintieshoukuan",
    data: {
        deptid: $("#deptid").val(),		// 单位ID

        jingfeideptlist: [],// 单位经费批次list
        shoukuanMonthList: [],// 单位经费批次月份list

        //查询用字段
        piciname: '',

    },
    created: function () {
        var _this = this;

        if (_this.deptid=='000'){
            $("#shoukuantab").hide();
        }

        _this.bindJingfeiDeptList();
    },
    methods: {

        toShoukuan: function () {
            $.modal.parentTab("津贴收款","/system/jintieguanli/jintieshoukuan");
        },

        toBofu: function () {
            $.modal.parentTab("津贴拨付","/system/jingfeipici/dangpicibofu");
        },

        // 根据单位ID查询 单位经费批次
        bindJingfeiDeptList: function () {
            var _this = this;
            $.post('/system/jingfeidept/pici_list', {
                piciname: _this.piciname
            }, function (ppData) {
                if (ppData != null) {
                    if (ppData.result == 1) {
                        var data = ppData.resultContent;
                        _this.jingfeideptlist = data;
                    } else {
                        layer.alert(ppData.message);
                    }
                }
            }, "json");
        },

        bindJingfeiDeptMonthList: function (jingfeideptitem) {
            var _this = this;
            $.post('/system/jingfeideptmonth/findmonthlist', {
                piciid: jingfeideptitem.jingfeipiciid,
                deptid: jingfeideptitem.deptid
            }, function (ppData) {
                if (ppData != null) {
                    if (ppData.result == 1) {
                        var data = ppData.resultContent;
                        _this.shoukuanMonthList = data;
                    } else {
                        layer.alert(ppData.message);
                    }
                }
            }, "json");
        },

        //确认收款
        QuerenShoukuan: function (jingfeideptitem) {
            var _this = this;
            var jingfeipici_layer = layer.open({type: 3});
            $.post('/system/jisuan/shoukuan', {
                id: jingfeideptitem.id,
            }, function (ppData) {
                layer.close(jingfeipici_layer);
                if (ppData != null) {
                    if (ppData.result == 1) {
                        layer.open({
                            time: 1000,
                            btn: [],
                            content: "收款成功!",
                        })
                        _this.bindJingfeiDeptList()
                    } else {
                        layer.alert(ppData.message);
                    }
                }
            }, "json");
        },

        toXiangqing: function (jingfeipiciitem) {
            $("#shoukuanxiangqingLabel").html("收款详情");
            this.bindJingfeiDeptMonthList(jingfeipiciitem)
            $("#shoukuanxiangqingModal").modal();
        },

        //重置
        Reset: function () {
            this.picimingcheng=null;
            this.bindJingfeiDeptList();
        }

    },
})